package com.songlanyun.modules.order.model.vo;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.Week;
import com.songlanyun.common.drive.ValueObject;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 订单统计
 */
@Data
public class SaleStatisticsVo implements ValueObject {

    /**
     * 时间字符串（07-02周一）
     */
    private String timeStr;

    /**
     * 日期
     */
    private DateTime dateTime;

    /**
     * 订单数
     */
    private Integer orderNum;


    /**
     * 销售额
     */
    private BigDecimal orderAmount;

    public void setDateTime(DateTime dateTime)
    {
        this.dateTime = dateTime;
        Week week = DateUtil.dayOfWeekEnum(dateTime.toJdkDate());
        String format = DateUtil.format(this.dateTime, "MM-dd");
        this.timeStr = format+ weekStr(week);
    }

    private String weekStr(Week week)
    {
        switch (week)
        {
            case SUNDAY:
                return "周日";
            case MONDAY:
                return "周一";
            case TUESDAY:
                return "周二";
            case WEDNESDAY:
                return "周三";
            case THURSDAY:
                return "周四";
            case FRIDAY:
                return "周五";
            case SATURDAY:
                return "周六";
            default:
                return "";
        }
    }
}
